package com.work.principle.config;

import com.work.principle.model.Dog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-06-24
 * Time:16:20
 */
@Configuration
public class DogConfig {
    @Bean
    public Dog dog(){
        Dog dog =new Dog();
        dog.setName("xiaohuang");
        return dog;
    }

    @Bean//单例
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    public Dog singletonDog(){
        return new Dog();
    }

    @Bean//原型
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Dog prototypeDog(){
        return new Dog();
    }

    @Bean//请求
    @RequestScope
    public Dog requestDog(){
        return new Dog();
    }

    @Bean//会话
    @SessionScope
    public Dog sessionDog(){
        return new Dog();
    }

    @Bean//全局
    @ApplicationScope
    public Dog ApplicationDog(){
        return new Dog();
    }

}
